package com.apes.scm.masterdata.product.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * @BelongsProject: apes-server
 * @BelongsPackage: com.apes.scm.masterdata.product.model
 * @ClassName: ProductServiceHours
 * @Author: pyb
 * @CreateTime: 2020-02-06 14:29
 * @Description: 商品服务工时
 * @Version: 1.0
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = ProductServiceHours.CONST_TABLE_NAME,indexes = {
        @Index(name = "IDX_PRODUCT", columnList = "product_id", unique = true)
})
public class ProductServiceHours extends Model {
    public static final String CONST_TABLE_NAME = "mas_product_service_hours";
    @Id
    @Column(name = "id", length = 10)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "商品服务工时", padding = 10)
    @Comment("服务编码")
    private String id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "product_id", referencedColumnName = "id")
    @Comment("商品")
    private Product product;

    @Column(name = "service_hours")
    @Comment("施工时长")
    private int serviceHours;

    @Column(name = "valid", nullable = false, columnDefinition = "number(1, 0) default 1")
    @Comment("有效标记")
    private boolean valid; // 有效标记

}
